<?php

namespace catchAdmin\pc\tables;

use catchAdmin\pc\tables\forms\Factory;
use catcher\CatchTable;
use catcher\library\table\Actions;
use catcher\library\table\HeaderItem;
use catcher\library\table\Search;

class News extends CatchTable
{

    public function Table()
    {
        return $this
            ->getTable('news')
            ->header([
                HeaderItem::label('标题')->prop('title')->width('200'),
                HeaderItem::label('简介')->prop('short_content'),
                HeaderItem::label('分类')->prop('class_name'),
                HeaderItem::label('发布人')->prop('fa_name')->width('200'),
                HeaderItem::label('轮播图')->prop('banner_is_show')->width('200'),
                HeaderItem::label('权重')->prop('sort')->width('200'),
                HeaderItem::label('浏览数')->prop('view_count')->width('200'),
                HeaderItem::label('发布时间')->prop('created_at')->width('200'),
                HeaderItem::label('操作')
                    ->actions([
                        Actions::normal('编辑', 'zz3', 'editNews', 'el-icon-s-tools'),
                        Actions::delete(),
                    ])
                    ->width(260),
            ])
            ->withSearch([
                Search::label('标题')->text('title', '标题')->clearable(true),
                Search::label('发布人')->text('fa_name', '发布人')->clearable(true),
            ])
            ->selectionChange()
            ->withApiRoute('news')
            ->withActions([
                Actions::normal('新建', 'success', 'handleCreate1'),
            ])
            ->render();
    }


    public function form()
    {
        return Factory::create('news');
    }

}
